package site.openapi.sdk;

import org.junit.jupiter.api.Test;
import site.openapi.sdk.api.UserApi;
import site.openapi.sdk.invoker.ApiClient;
import site.openapi.sdk.invoker.ApiException;
import site.openapi.sdk.invoker.Configuration;
import site.openapi.sdk.model.User;

/**
 * @author
 * @since 1.0.0
 * <p/>
 * <p>
 * <p/>
 *
 * <h4>Record list</h4>
 * 2025/11/5 13:44 init </br>
 */
public class UserTester {
    @Test
    public void test() {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
//        defaultClient.setBasePath("http://localhost:8081");

        UserApi apiInstance = new UserApi(defaultClient);
        User user = new User(); // User |
        user.setId(1L);
        user.setFirstName("John");
        user.setLastName("Doe");
        user.setEmail("john.doe@example.com");
        user.setPassword("password");
        user.setUserStatus(1);
        user.setUsername("john");
        user.setPhone("123456789");
        try {
            User result = apiInstance.createUser(user);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling UserApi#createUser");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }

    @Test
    public void test2() {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
//        defaultClient.setBasePath("http://localhost:8081");

        UserApi apiInstance = new UserApi(defaultClient);
        try {
            User result = apiInstance.getUserByName("john");
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling UserApi#createUser");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
